﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TestEventDispatcher : MonoBehaviour
{
    NetMessage msg;
    private void Awake()
    {
        EventDispatcher.Instance.AddEventListener((uint)MSG_TYPE.CMD_LOGIN_RES, OnLoginCmd);
    }


    // Update is called once per frame
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            msg = new NetMessage((uint)MSG_TYPE.CMD_LOGIN_RES, "On Login Success");
            EventDispatcher.Instance.ProcessMsg(msg);
        }
    }

    /// <summary>
    /// 回调事件
    /// </summary>
    /// <param name="msg"></param>
    public void OnLoginCmd(NetMessage msg)
    {
        Debug.LogError(msg.Id +" "+msg.Str);
    }
}
